<%@ include file="/common/taglibs.jsp"%>
<%@ include file="/common/loginredirect.jsp"%>
<head>
    <title><fmt:message key="menu.js2"/></title>
    <meta name="heading" content="<fmt:message key='workPosition.workPosition'/>"/>
    <meta name="menu" content="FormsMenu"/>
</head>




<div class="jquery_tab_container">
    <span class="heading_tab advanced_link active tab1"><fmt:message key="menu.js2"/></span>
</div>

<div class="jquery_tab">
    <div class="content_block"></div>

<form:form commandName="workPositionForm" method="post" action="workpositionsearch" id="workPositionForm" onsubmit="return validateWorkPositionForm(this)">
    <form:errors path="*" cssClass="error" element="div"/>
    <form:hidden path="workPosition.id"/>

        <p class="buttonBar bottom"  style="border-bottom: 1px solid #ccc; margin-bottom: 10px;">
<input class="button" type="button" style="margin-right: 5px" onclick="location.href='<c:url value="/workpositionsearchformprijava"/>'" value="<fmt:message key="button.dodadiPrijava"/>"/>
<input class="button" type="button" style="margin-right: 5px" onclick="location.href='<c:url value="/workpositionsearchformodjava"/>'" value="<fmt:message key="button.dodadiOdjava"/>"/>
    </p>
    <h3><fmt:message key="search.workposition" /></h3><br />
            <p>
                <appfuse:label styleClass="width100 left" key="basicInfo.firstName"/>    
                <form:input path="workPosition.employment.firstName" id="workPosition.employment.firstName" cssClass="left input-medium toCyr"/>
                <br class="clearboth" />
            </p>
            <p>
                <appfuse:label styleClass="width100 left" key="basicInfo.lastName"/>
                <form:input path="workPosition.employment.lastName" id="workPosition.employment.lastName" cssClass="left input-medium toCyr"/>
                <br class="clearboth" />
            </p>
            <p>
            <appfuse:label styleClass="width100 left" key="basicInfo.socScrNo"/>
           
            <form:input path="workPosition.employment.socScrNo" id="workPosition.employment.socScrNo" cssClass="left input-medium toCyr"/>
        <br class="clearboth" />
            </p>
            <p>
            <appfuse:label styleClass="width100 left" key="basicInfo.position"/>
          
            <form:input path="workPosition.position" id="workPosition.employment.socScrNo" cssClass="left input-medium toCyr"/>
          <br class="clearboth" />
            </p>

            <p>
            <appfuse:label styleClass="width100 left" key="basicInfo.experience"/>
     
            <form:input path="workPosition.experience" id="workPosition.employment.socScrNo" cssClass="left input-medium toCyr"/>
        <br class="clearboth" />
            </p>

            <p>
            <appfuse:label styleClass="width100 left" key="basicInfo.date"/>
            <form:input path="workPosition.startDate" value="" name="flexy_datepicker" id="workPosition.startDate" cssClass="left input-medium toCyr"/>
              <br class="clearboth" />
            </p>

            <p>
            <appfuse:label styleClass="width100 left" key="searchPerson.WorkPositionType"/>
            <form:select path="workPosition.discriminator" id="workPosition.discriminator">
                <form:option id="1" value="">
                    <fmt:message key='tipObrazecIzbor'/>
                </form:option>
                <c:if test="${'1' == workPositionForm.workPosition.discriminator}"> 
                    <form:option id="2" value="Prijava" selected="true" >
                        <fmt:message key='prijava'/>
                    </form:option> 
                </c:if>  
                <c:if test="${'1' != workPositionForm.workPosition.discriminator}"> 
                    <form:option id="2" value="Prijava" >
                        <fmt:message key='prijava'/>
                    </form:option> 
                </c:if>
                <c:if test="${'0' == workPositionForm.workPosition.discriminator}"> 
                    <form:option id="3" value="Odjava" selected="true">
                        <fmt:message key='odjava'/>
                    </form:option>
                        
                </c:if>  
                <c:if test="${'0' != workPositionForm.workPosition.discriminator }"> 
                    <form:option id="3" value="Odjava" >
                        <fmt:message key='odjava'/>
                    </form:option> 
                </c:if>
            </form:select>
                 <br class="clearboth" />
            </p>

            <p>
            <appfuse:label styleClass="width100 left" key="workPosition.employmentReason"/>
            <form:select path="workPosition.emplReason.id" id="employmentReasonSelect">
                <form:option id="1" value="">
                    <fmt:message key='osnovPrijavaIzbor'/>
                </form:option>
                <c:forEach items="${workPositionForm.employmentReason}" var="employmentReason">

                    <c:if test="${employmentReason == workPositionForm.workPosition.emplReason}">
                        <form:option value="${employmentReason.id}" id="${workPositionForm.workPosition.emplReason.id}" selected="true">
                            ${employmentReason.name}
                        </form:option>
                    </c:if>
                    <c:if test="${employmentReason != workPositionForm.workPosition.emplReason}">
                        <form:option value="${employmentReason.id}" id="${workPositionForm.workPosition.emplReason.id}" >
                            ${employmentReason.name}
                        </form:option>
                    </c:if>
                </c:forEach>
            </form:select>
            </p>

            <p>
            <appfuse:label styleClass="width100 left" key="workPosition.leaveReason"/>
            <form:select path="workPosition.leaveReason.id" id="leaveReasonSelect">
                <form:option id="1" value="">
                    <fmt:message key='osnovOdjavaIzbor'/>
                </form:option>
                <c:forEach items="${workPositionForm.leaveReason}" var="leaveReason">

                    <c:if test="${leaveReason == workPositionForm.workPosition.leaveReason}">
                        <form:option value="${leaveReason.id}" id="${workPositionForm.workPosition.leaveReason.id}" selected="true">
                            ${leaveReason.name}
                        </form:option>
                    </c:if>
                    <c:if test="${leaveReason != workPositionForm.workPosition.leaveReason}">
                        <form:option value="${leaveReason.id}" id="${workPositionForm.workPosition.leaveReason.id}" >
                            ${leaveReason.name}
                        </form:option>
                    </c:if>
                </c:forEach>
            </form:select>
            </p>

<input type="submit" class="button" name="workpositionsearch" value="<fmt:message key="button.search"/>"/>
<input type="button" class="button" onclick="location.href='<c:url value="/menuForms"/>'" value="<fmt:message key="button.cancel"/>"/>

</form:form>
<br /><br />    
<display:table name="workpositionList" class="table" requestURI="" id="workpositionList" export="false" pagesize="25">
    
    <display:column href="workpositionformprijava?" media="html"
                    paramId="idn" paramProperty="id"  property="employment.firstName" sortable="true" titleKey="workPosition.firstName"/>
    <display:column property="employment.lastName" sortable="true" titleKey="workPosition.lastName"/>
    <display:column property="employment.socScrNo" sortable="true" titleKey="workPosition.socScrNo"/>
    <display:column class="genderType" property="employment.gender" sortable="true" titleKey="workPosition.gender"/>
    <display:column property="institution.institutionName" sortable="true" titleKey="workPosition.institutionName"/>
    <display:column class="typeId" property="discriminator" sortable="true" titleKey="workPosition.discriminator"/>
    <display:column property="position" sortable="true" titleKey="workPosition.position"/>
    <display:column property="startDate" sortable="true" titleKey="workPosition.startDate"/>
    
    <%--<c:if test=\"${'1' != discriminator}\"><fmt:message key='prijava'/></c:if>--%>
   
    <display:setProperty name="paging.banner.item_name"><fmt:message key="workPosition.workPosition"/></display:setProperty>
    <display:setProperty name="paging.banner.items_name"><fmt:message key="workPosition.workPosition"/></display:setProperty>

   </display:table>

</div>
<script type="text/javascript">
    highlightTableRows("workpositionList");

    jQuery("#workpositionList tbody tr a").each(function () {
        var elem = jQuery(this);
        var elemType = elem.parent().siblings(".typeId");
        
        if (elemType.html() == 0) {

            var link = elem.attr("href");            
            var newLink = link.substring(0,16)+"odjava"+link.substring(23,link.length);
            elem.attr("href", newLink);
        }
       
    });

    var elems = jQuery(".typeId");
    elems.each(function (el) {
        var elem = jQuery(elems[el]);
        if (elem.html() == "1") {
            elem.html("<fmt:message key='prijava'/>");
        }
        else {
            elem.html("<fmt:message key='odjava'/>");
        }      
    });

    var elems = jQuery(".genderType");
    elems.each(function (el) {
        var elem = jQuery(elems[el]);
        if (elem.html() == "Male") {
            elem.html("<fmt:message key='male'/>");
        }
        else {
            elem.html("<fmt:message key='female'/>");
        }
    });

</script> 
